package com.ytjj.qmyx.admin.model.data.mongo;

import com.ytjj.common.dto.mqdto.PageStatisticsDto;
import com.ytjj.qmyx.admin.utils.CalendarUtil;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

/**
 * mongodb 页面统计实体
 *
 *
 *  *
 **/
@Document(collection="page_statistics")
@Data
public class PageStatistics {

    @Id
    private String _id;

    /**
     * uuid
     */
    private String uuid;

    /**
     * ip
     */
    private String ip;

    /**
     * 机型
     */
    private String model;

    /**
     * 现在的页面
     */
    private String fromPage;

    /**
     * 去到的页面
     */
    private String toPage;

    /**
     * 参数
     */
    private String param;

    /**
     * 平台
     */
    private String platform;

    /**
     * 渠道
     */
    private String channel;

    /**
     * 请求时间
     */
    private Date createTime;

    /**
     * 日期 2014-11-10
     */
    private String dayTime;

    /**
     * 小时时间  0  1  2  13  23
     */
    private Integer hourTime;

    /**
     * 浏览时间
     */
    private Long browseTime;

    /**
     * 页面路径对应CODE
     */
    private String pathCode;


    public PageStatistics() {
        this.browseTime = 1L;
    }

    public void copyProperty(PageStatisticsDto pageStatisticsDto) {
        this.setUuid(pageStatisticsDto.getUuid());
        this.setIp(pageStatisticsDto.getIp());
        this.setModel(pageStatisticsDto.getModel());
        this.setFromPage(pageStatisticsDto.getFromPage());
        this.setToPage(pageStatisticsDto.getToPage());
        this.setParam(pageStatisticsDto.getParam());
        this.setPlatform(pageStatisticsDto.getPlatform());
        this.setChannel(pageStatisticsDto.getChannel());
        this.setCreateTime(pageStatisticsDto.getCreateTime());
        this.dayTime = CalendarUtil.dateFormat(pageStatisticsDto.getCreateTime());
        this.hourTime = Integer.parseInt(CalendarUtil.dateFormatHour(pageStatisticsDto.getCreateTime()));
    }

}
